package com.sk.commonadapter_android.adapter.refresh;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.sk.commonadapter_android.R;

/**
 * @Author yemao
 * @Email yrmao9893@163.com
 * @Date 2017/6/13
 * @Des null!
 */

public class LoadMoreLayout extends LinearLayout{
    public final static int STATE_LOADING = 0;
    public final static int STATE_COMPLETE = 1;
    public final static int STATE_NOMORE = 2;
    private TextView mTextView;
    private ProgressBar mProgressBar;
    public LoadMoreLayout(Context context) {
        super(context);
        initView(context);
    }

    public LoadMoreLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }
    private void initView(Context mContext) {

        LayoutInflater.from(mContext).inflate(R.layout.common_refresh_footer,this);
        mTextView= (TextView) findViewById(R.id.tv_state);
        mProgressBar= (ProgressBar) findViewById(R.id.progress_bar);
        setState(STATE_COMPLETE);

    }
    public void  setState(int state){
        switch (state){
            case STATE_COMPLETE:
                mTextView.setText(getContext().getString(R.string.listview_load_comlete));
                mProgressBar.setVisibility(GONE);
                break;
            case STATE_LOADING:
                mTextView.setText(getContext().getString(R.string.listview_loading));
                mProgressBar.setVisibility(VISIBLE);
                break;
            case STATE_NOMORE:
                mTextView.setText(getContext().getString(R.string.nomore_loading));
                mProgressBar.setVisibility(GONE);
                break;
        }
    }

}
